﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace ControleEstoque.PDA
{
	public partial class RealizarConsulta : UserControl
	{
		private const string HtmlBody = @"<HTML>
	<HEAD>
		<SCRIPT language=""javascript"">
function toogleVisibility(controlId){
	var control = document.getElementById(controlId);
	
	if(control){
		if(control.style.display == ""none""){
			control.style.display = """";
		}
		else{
			control.style.display = ""none"";
		}
	}
}
		</SCRIPT>
	</HEAD>
	<BODY>
		{0}
	</BODY>
</HTML>";

		public RealizarConsulta()
		{
			InitializeComponent();

			this.ativoBindingSource.DataSource = Program.CurrentService.Ativo_GetDataWithFabricanteAtivoNomeAndTipoAtivoNome();
			this.localArmazenagemBindingSource.DataSource = Program.CurrentService.LocalArmazenagem_GetData();
		}

		private void btnConsultar_Click(object sender, EventArgs e)
		{
			string result = Program.CurrentService.EstoqueLocalizacao_ConsultarEstoque(this.cbAtivoId.SelectedValue as int?, this.cbLocalArmazenagemId.SelectedValue as int?, txtEstoqueLocalizacaoRFID.Text, (dpMovimentacaoDataInicial.Enabled ? dpMovimentacaoDataInicial.Value as DateTime? : null), (dpMovimentacaoDataFinal.Enabled ? dpMovimentacaoDataFinal.Value as DateTime? : null));


			this.wbResults.DocumentText = @"<HTML>
	<HEAD>
		<SCRIPT language=""javascript"">
function toogleVisibility(controlId){
	var control = document.getElementById(controlId);
	
	if(control){
		if(control.style.display == ""none""){
			control.style.display = """";
		}
		else{
			control.style.display = ""none"";
		}
	}
}
		</SCRIPT>
	</HEAD>
	<BODY>" + result.Replace("display: none", string.Empty) + @"</BODY>
</HTML>";
			this.tabControl1.SelectedIndex = 1;
		}
	}
}
